<template>
	<div v-if="notFound">
		<div v-show="loadingShow">
			<loading></loading>
		</div>
		<div v-else>
			<div class="details-index">
				<div>
					<details-focus></details-focus>
					<details-basic-info :sale="rangeStore"></details-basic-info>
					<detaile-choose-info></detaile-choose-info>
					<details-recommend-combonation></details-recommend-combonation>
					<details-commodity-info></details-commodity-info>
					<div class="bespeakbox">
						<div class="bespeak">
							<button class="order" v-if="placeOrder && isSale" @click="bookingOrder | debounce 500" ca="P_{{spuInfo.spuName}}$预约下单">预约下单</button>
							<button class="not-sales" ca="P_{{spuInfo.spuName}}$暂不销售" v-else>暂不销售</button>
						</div>
						
					</div>

					<!--shop manager  v-if="isShowManger"-->
					
					<div v-if="isShowManger" class="manager" @click="toManager">
						<i class="icon-manager"></i>
						<span>咨询店长</span>
					</div>
<!-- 					<div class="bespeak">
						<button class="order" v-if="placeOrder && isSale" @click="bookingOrder | debounce 500" ca="P_{{spuInfo.spuName}}$预约下单">预约下单</button>
						<button class="not-sales" ca="P_{{spuInfo.spuName}}$暂不销售" v-else>暂不销售</button>
					</div> -->
					<div>
		  				<!--<iframe :src="iframe" style="display: none" v-if="isIOSWechat"></iframe>-->
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	
	// import detailsFocus from './details-focus';
	// import detailsBasicInfo from './details-basic-info';
	// import detaileChooseInfo from './detaile-choose-info';
	// import detailsRecommendCombonation from './details-recommend-combonation';
	// import detailsCommodityInfo from './details-commodity-info';	
	import loading from '../common/loading';	
	import common from '../../utils/common';


	import Vue from 'vue';
	import {Toast,MessageBox} from 'mint-ui';

	export default {
		data: function () {
			return {
				detailsFocusD: {}, // 焦点图 - 数据
				detailsBasicInfo: '', // basic info - 数据
				detaileChooseInfo: '',
				detailsRecommendCombonation: '', // 推荐组合套餐 - 数据 
				detailsCommodityInfo: '',
				richId:'',             // 详情富文本ID
				storeInfo: {}, // 门店信息
				carInfo: {}, // 车辆信息
				placeOrder: true,	 // 下订单
				spuCodeData: '', // supCode
				spuInfoBasic: {}, // supInfo 
				loadingShow: true, // loading
				infoNull: false,
				spuCommonData: {},
				skuCode: '',
				spuInfo:'',
				spuCode:'',
				carRelation:'',
				skuInfo:'',
				shareTitle:'商品详情分享',
				shareImg:'',
				
				isSale: true, // 默认是 true，表示在 单商品 且 是priceType == 1 [渠道价] 

				active: 0,  // 设置loading值
				notFound: true, // 404效果显示处理
				rangeStore: false, // 门店是否存在范围

				// inittime:'',
				// time1:'',
				// time2:'',
				// time3:'',
				// time4:'',
				// time5:'',
				//iframe:'',
				isIOSWechat: common.isIOSWechat(),
				storeInfoType:'',


				url:window.location.href.replace('#!','@@@'),
				isShowManger:false,
				price:'',
				isChat:0


			}
		},
		watch: {
			//监听商品详情
			// 'richId': function(){
				
			// 	var _this = this,
			// 		richId = _this.richId;
			// 	this.$http.post(common.isdev()+'/detail/richDetail.htm',{
			// 		richId: richId
			// 	}).then(function ( d ) {
			// 		var res = JSON.parse(d.data);
					
			// 		if(res.result === 1){
			// 			_this.detailsCommodityInfo = res.msg;

			// 			_this.$broadcast('detailsCommodityInfo', _this.detailsCommodityInfo);
			// 		} else if ( res.result === 0 ) {
			// 			Toast(res.message);
			// 		}
					
			// 	}, function( err ) {
			// 		Toast(err);
			// 	});
			// }
		},

		components: {
			//detailsFocus, detaileChooseInfo, detailsBasicInfo, detailsRecommendCombonation, detailsCommodityInfo,loading
			loading,common,
			'detailsFocus': function ( resolve, reject ) {
				require.ensure([], function ( require ) {
					resolve(require('./details-focus'));
				}, 'detailsFocus');
			},
			'detailsBasicInfo': function ( resolve, reject ) {
				require.ensure([], function ( require ) {
					resolve(require('./details-basic-info'));
				}, 'detailsBasicInfo');
			},
			'detaileChooseInfo': function ( resolve, reject ) {
				require.ensure([], function ( require ) {
					resolve(require('./detaile-choose-info'));
				}, 'detaileChooseInfo');
			},
			'detailsRecommendCombonation': function ( resolve, reject ) {
				require.ensure([], function ( require ) {
					resolve(require('./details-recommend-combonation'));
				}, 'detailsRecommendCombonation');
			},
			'detailsCommodityInfo': function ( resolve, reject ) {
				require.ensure([], function ( require ) {
					resolve(require('./details-commodity-info'));
				}, 'detailsCommodityInfo');
			}
		},
		events: {
			changeSkuCode:function(skuCode){
				//console.info('changeSkuCode');
				//form spu-common changeSkuCode
				sessionStorage.changeSkuCode = JSON.stringify(skuCode);

				this.skuCode = skuCode;

				this.skuDetails();
			}
		},
		route: {
			data: function () {
				//this.inittime = new Date().getTime();
				//console.log('开始成功：' + this.inittime);	
				var _this = this;
				
				// 商品详情
				// 获取维度
				var _spuCode = this.$route.params.spuCode;
				//debugger;
				if(sessionStorage.thisSpuId != _spuCode){

					sessionStorage.removeItem('colorSize');
					sessionStorage.removeItem('selectVd');
					sessionStorage.removeItem('changeSkuCode');

				}
					this.placeOrder = true;
					this.isSale = true;

				this.spuCode = _spuCode;
				console.log(_spuCode);
				// 存在SpuCode
				if ( _spuCode ){

					// 处理 Loading图
					Vue.http.interceptors.push(function ( request, next ) {
						next(function ( response ) {
//							if ( this.active == 1 ) {
								this.loadingShow = false;
								return response;
//							}
						});
					});
					_this.spuCodeData = _spuCode;
					_this.$http.post( common.isdev() + '/detail/spuDetail.htm',{
						spuCode: _spuCode
					}).then(function ( d ) {

						//this.time1 = new Date().getTime();	
						//console.log('页面请求成功:spuDetails：' + parseInt(this.time1 - this.inittime));				
						var res = typeof d.data === 'object' ? d.data : JSON.parse(d.data);						
						var finallyDetailsFocusData = {};
						var _skuCode = '';
						
						// 设置loading值
//						this.active += 3;
						
						if ( res.result === 1 ) {
							common.setTitle(res.obj.spuInfo.spuName);  // 设置title
							//common.setTitleAgain();
							//document.title = '车享家 -' + res.obj.spuInfo.spuName + '商品详情';
							_this.spuInfo = res.obj.spuInfo;
							if ( res.obj && typeof res.obj == 'object' ) {
								finallyDetailsFocusData['spuName'] = res.obj.spuInfo.spuName;	
								finallyDetailsFocusData['androidImageList'] = res.obj.spuInfo.androidImageList;
								
								// detailsFocus  
								for ( var i in finallyDetailsFocusData ) {
									Vue.set(_this.detailsFocusD, i, finallyDetailsFocusData[i] );
								}
								_this.$broadcast('detailsFocusDataEvent', _this.detailsFocusD);

								// chooseInfo  
								_this.detaileChooseInfo = res.obj;
								_this.$broadcast('chooseInfoDataEvent', _this.detaileChooseInfo);
			
								// 设置 richId
								//_this.richId = res.obj.spuInfo.richMobileDetail;
								_this.detailsCommodityInfo = res.obj.spuInfo.richMobileDetail;
								
								_this.$broadcast('detailsCommodityInfo', _this.detailsCommodityInfo);
								// detailsBasicInfo
								_this.spuInfoBasic.spuName = res.obj.spuInfo.spuName;
								_this.spuInfoBasic.fixedPrice = res.obj.spuInfo.fixedPrice;
								_this.spuInfoBasic.iscombined = res.obj.spuInfo.iscombined; 
								_this.spuCommonData.spuName = res.obj.spuInfo.spuName;
								_this.spuCommonData.androidMainImage = res.obj.spuInfo.androidMainImage;
								
								// 传递商品名字
								_this.$broadcast('detailsBasicInfoSpuName', _this.spuInfoBasic);
								_this.$broadcast('spuCommonData', _this.spuCommonData);								
								
								// 存储skuCode
								_skuCode = res.obj.spuInfo.skuCode;

								this.skuCode = sessionStorage.changeSkuCode == undefined ? _skuCode : JSON.parse(sessionStorage.changeSkuCode);

								// 车辆是否必须
								this.carRelation = (this.spuInfo.carRelation =='1'|| this.spuInfo.carRelation =='2')?true:false;
								// 获取车辆 门店信息初始化
								_this.initStore();
								
								//判断商品是否是可售状态
								if(res.obj.spuInfo.status !== '4'){
									this.rangeStore = true;  // 商品status状态不等4的时候，价格显示 暂不可售。
									this.placeOrder = false;  // 商品status状态不等4的时候，按钮置灰。
								}
												
								if(res.obj.spuInfo.iscombined != '2'){
									// 推荐组合套餐
									this.$http.post(common.isdev()+'/combineSku/combineDetail.htm', {
										skuCode: _skuCode,
										channelType: 1
									}).then(function ( d ) {		
										var resData = typeof d.data === 'object' ? d.data : JSON.parse(d.data);									
										if ( resData.result && resData.result === 1 ) {
											// 写入data
											_this.detailsRecommendCombonation = resData.obj.mdseCacheCmbVO;
											_this.$broadcast('recommendCombonationDataEvent', _this.detailsRecommendCombonation, _this.spuInfo.spuName);
										} else if ( resData.result === 0 ) {
											this.$broadcast('recommendCombonationDataEvent', '');
											if(resData.message){

												Toast( resData.message );
											}
											
										}
										
//										this.active -= 1;
									}, function () {
										Toast('推荐组合套餐返回出错');
									});	
								}
							
							}
							this.notFound = true;
						} else if( res.result === 0 ) {
//							Toast('商品详情，请求错误');
							this.notFound = false;
							common.goNotFound(res.errorCode);
						}
						
					}, function( err ) {
//						Toast('请求错误');
//						common.goNotFound();
					});
				} else {
					//debugger;
					// 404
//					_this.$route.router.go({'name': 'notfile'});
					/******** 修改404页面 ********/
					this.notFound = false;
					common.goNotFound();
					/******** 修改404页面 ********/
				}
				
			}	
		},
		ready: function () {
			common.ANA_Analytics();

/*			this.iframe = common.setTitleAgain('商品详情', this.iframe);
			
			this.setTitle('商品详情')	;
*/			// 传递提交页面
			// var confirmObj = {
			// 	recommendCodeShow: true,
			// 	carShow: true,
			// 	stroeShow: true,
			// 	time: true,
			// 	orderType: '02'
			// } 
		
			// localStorage.setItem('confirmObj', JSON.stringify(confirmObj));
				
		},
		destroyed(){
			if(common.getappVersion()<40)return;
			lb.hideMenu();
		},
		methods: {
			share(price){
				//debugger;
				if(common.getappVersion()<40)return;
				var shareDate = {
					title:this.spuInfo.shortName||'',
					content:'我在车享家发现了个不错的服务商品',
					imgUrl:this.spuInfo.androidImageList[0].sourceFullImage||'',
					url:this.url
				}
				//打开菜单
				lb.showMenu({
					wx:shareDate,
					wxtl:shareDate
				});
				//分享内容

				lb.menuShareMsg({
					wx:shareDate,
					wxtl:shareDate
				});
			},
			toManager(price){
				if(common.getappVersion()<40)return;
				var defText=[],attrValue = this.spuInfo.attrValue;
				if(attrValue){
					for(var i=0,len=attrValue.length;i<len;i++){
						defText.push(this.spuInfo.attrMap[attrValue[i]]);
					}
				}


				lb.openIM({
					storeId:this.storeInfo.storeId,
					title:this.spuInfo.spuName+ (defText?defText.join('/'):''),
					subtitle:this.price,
					icon:this.spuInfo.androidMainImage,
					url:this.url
				});
			},
			getPrice () {
				var _this = this;
				/**
				 * 详情页的促销，价格接口 
				 * 查询价格及促销信息
				 */
    
				var prmtQuery = JSON.stringify({
					"skuCode": _this.skuCode,
					'provinceCode':_this.storeInfo.provinceId,
					'cityCode':_this.storeInfo.cityId,
					'areaCode':_this.storeInfo.distId,
					'entityStore':_this.storeInfo.partnerCode
				});

				this.$http.post(common.isdev()+'/pricePrmtHandle/queryCxjMdsePricePrmt.htm', {					
					prmtQuery: prmtQuery
				}).then(function ( d ) {

						this.isSale = true;

						//this.time3 = new Date().getTime();	
						//console.log('页面请求价格 成功:queryCxjMdsePricePrmt：' + parseInt(this.time3 - this.inittime));	
					//debugger;					

					var resData = typeof d.data === 'object' ? d.data : JSON.parse(d.data);
					if ( resData.result === 1 ) {
						_this.detailsBasicInfo = resData.obj;
						_this.$broadcast('detailsBasicInfoEvent', _this.detailsBasicInfo);
						//_this.$broadcast('detailsBasicInfoPrice', resData.obj.price);
						/********** 修改组合商品 iscombined [iscombined=2 组合商品 ] 且  priceType == 1 [渠道价] 是暂不销售 **********/
						if ( _this.spuInfoBasic.iscombined != 2 && _this.detailsBasicInfo.price.priceType == 1 ) {
							// （渠道价&&非组合商品）价格地方展示暂不销售，按钮置灰
							this.rangeStore = true; 
							this.isSale = false;
						};


						// 当无爱车信息  强或者弱关联时候 可售时 并且spucode第一次进来时提示添加爱车
						if(!_this.carInfo.carName && _this.carRelation && _this.isSale && (_this.spuCode != sessionStorage.thisSpuId)){
							_this.showMessAddCar();
						}

						// 设置session spucode，用来判断时候为首次进入的spucode
						sessionStorage.thisSpuId = _this.spuCode;
						
						/********** 修改组合商品 且  priceType == 1 [渠道价] 是暂不销售  **********/
					} else if ( resData.result === 0 && resData.message) {
						Toast(resData.message);
					}

					//isChat是1 并且是APP渠道，并且版本大于等于4.0
					

					if(this.isChat===1 && common.isApp() && common.getappVersion()>=40){
						this.isShowManger = true;
					}else{
						this.isShowManger = false;
					}
					
					this.price = resData.obj.price.cashPrice||resData.obj.price.marketPrice;

					this.share(this.price);
					
					
				}, function ( err ) {
					// 价格接口异常判断，价格地方展示暂不销售，按钮置灰
					this.rangeStore = true; 
					this.isSale = false;
					if(err){
						Toast(err);
					}

					if(this.isChat===1 && common.isApp() && common.getappVersion()>=40){
						this.isShowManger = true;
					}else{
						this.isShowManger = false;
					}
					
				});
			},
			showMessAddCar (){
				MessageBox({				  
				  message: '没有爱车，现在去添加爱车吧！',
				  showCancelButton: true,
				  confirmButtonText:'去添加',
				  cancelButtonText:'暂不添加'
				}).then(action => {
					if(action === 'confirm'){
						window.location.href = common.getLocation()+"/selectCar/redirect.htm?targetUrl="+encodeURIComponent(window.location.href);
					}
				});
			},
			
			// 初始化商店
			initStore: function (fnBack) {
				var _this = this;
				
				/********** 参数处理 storeId **********/
				var getInfoParam = { spuCode: this.$route.params.spuCode,targetJumpUrl:window.location.href};
				
				var param = '';
				// 判断参数位置
				if ( location.search == '' ) {
					// 取hash
					var hash = location.hash;
					// http://local.jia.sit.com:8080/#!/details/1043284 // location.search == ''
					// http://local.jia.sit.com:8080/#!/details/1043284?storeId=6&pink=100  // location.search == ''
					// http://h.jia.sit.com/spah5/#!/details/1043890?storeId=6
					var pos = hash.indexOf('?');
					param = pos > -1 ? hash.substr(pos) : hash;
				} else {
					// http://local.jia.sit.com:8080/?storeId=6&pink=100#!/details/1043284
					// ?storeId=11/
					param = location.search;
					try{
						var pos = param.indexOf('/'); 
						if ( pos > -1 ) {
							param = param.substr(0, pos); 			
						}
					} catch ( err ){}
					
				}
				
				var urlParam = param.indexOf('?') > -1 ? this.getUrlParam(param) : '';
				
				if ( urlParam.storeId && urlParam.storeId != 'undefined' && urlParam.storeId != 'null' ) {
					getInfoParam.storeId = urlParam.storeId; 	
				}
				/********** 参数处理 **********/
				
				// 商店请求
//			    $.postajax(common.isdev()+'/spu/getSelectedElementInfo.htm', {spuCode: this.$route.params.spuCode},function (data) {	
				this.$http.post(common.isdev() + '/spu/getSelectedElementInfo.htm', getInfoParam).then(function ( data ) {
						//this.time2 = new Date().getTime();	
						//console.log('页面请求门店、爱车 成功:getSelectedElementInfo：' + parseInt(this.time2 - this.inittime));	
						data = typeof data.body === 'object' ? data.body : JSON.parse(data.body);
						if ( data.result === 1 ) {
							if ( data.obj && typeof data.obj === 'object' ) {
								// 门店信息
								// storeinfo == null，价格地方展示暂不销售
								if ( !data.obj.storeInfo ) {
									this.rangeStore = true;				
								}
								
								if ( data.obj.storeInfo && typeof data.obj.storeInfo === 'object' ) {
									_this.storeInfo = data.obj.storeInfo;
									_this.storeInfoType = true;
									_this.isChat = _this.storeInfo.isChat;
									//debugger;
									//设置详情页面 直连店长与分享链接.   
									console.info(this.$route.path);
									var url =window.location.origin+'/store/setStore.htm?forwardUrl='+encodeURIComponent('/spah5/aaa/details/'+this.$route.params.spuCode+'?userInfo=&storeId='+this.storeInfo.storeId);

									//解决#！被路由截断问题
									this.url = url;
									console.info(this.url);


								}else{
									_this.storeInfoType = false;
								}
								// 车辆信息
								if ( data.obj.carInfo && typeof data.obj.carInfo === 'object' ) {
									_this.carInfo = data.obj.carInfo;
									//fnBack.call(this);									 
								}

								// storeinfo == null，服务门店不展示，按钮置灰
								if(!data.obj.storeInfo || !data.obj.storeInfo.storeName ){
									this.placeOrder = false;
									return;
								}

								// 多规格SKUCODE 当多规格存在时 直接请求多规格相关信息
								if(sessionStorage.changeSkuCode){
									//_this.getPrice();
									_this.skuDetails();
								}else{
									//获取价格
									_this.getPrice();
								}
								console.info(_this.storeInfo);

								// 发送到子组件
								_this.$broadcast('initStoreData', _this.storeInfo, _this.carInfo);
							}
						} else if ( data.result === 0 && data.result.message) {
							Toast(data.result.message);

						}else if( data.result === -100 ){							
							window.location.href =  '//'+window.location.hostname+ data.obj;
						}

//					this.active -= 1;	
					
			    });				
			},
			skuDetails(){
				var _this = this;
				
				// 商品详情			
				// 获取维度
				var _spuCode = this.$route.params.spuCode;
				this.spuCode = _spuCode;
				// 存在SpuCode
				if ( _spuCode && this.skuCode){
					_this.spuCodeData = _spuCode;


					_this.$http.post( common.isdev() + '/detail/skuDetail.htm',{
						skuCode: this.skuCode
					}).then(function ( d ) {
						this.placeOrder = true;
						var res = typeof d.data === 'object' ? d.data : JSON.parse(d.data);

						
						var finallyDetailsFocusData = {};
						var _skuCode = this.skuCode;
						if ( res.result === 1 ) {
							document.title = '车享家 -' + res.obj.mdseName + '商品详情';

							_this.skuInfo = res.obj;

							if ( res.obj && typeof res.obj == 'object' ) {
								finallyDetailsFocusData['spuName'] = res.obj.mdseName;	
								finallyDetailsFocusData['androidImageList'] = res.obj.skuAndroidImage;
								
								// detailsFocus  
								for ( var i in finallyDetailsFocusData ) {
									Vue.set(_this.detailsFocusD, i, finallyDetailsFocusData[i] );
								}
								_this.$broadcast('detailsFocusDataEvent', _this.detailsFocusD);


								// chooseInfo  
								// _this.detaileChooseInfo = res.obj;
								// _this.$broadcast('chooseInfoDataEvent', _this.detaileChooseInfo);
			
								// 设置 richId
								//_this.richId = res.obj.spuInfo.richDetail;
								
								// detailsBasicInfo
								_this.spuInfoBasic.spuName = res.obj.mdseName;
								_this.spuInfoBasic.fixedPrice = res.obj.fixedPrice;
								_this.spuCommonData.spuName = res.obj.spuName;
								_this.spuCommonData.androidMainImage = res.obj.androidMainImage;
								
								// 传递商品名字
								_this.$broadcast('detailsBasicInfoSpuName', _this.spuInfoBasic);
								//_this.$broadcast('spuCommonData', _this.spuCommonData);

								// 车辆是否必须
								this.carRelation = (res.obj.carRelation =='1'|| res.obj.carRelation =='2')?true:false;

								// 获取车辆 门店信息初始化
								//_this.initStore();
								//获取价格
								_this.getPrice();
								
								//判断商品是否是可售状态
								if(res.obj.status != '4'){
									this.rangeStore = true;  // 商品status状态不等4的时候，价格显示 暂不可售。
									this.placeOrder = false;  // 商品status状态不等4的时候，按钮置灰。
								}

								
								// 推荐组合套餐 start
								this.$http.post(common.isdev()+'/combineSku/combineDetail.htm', {
									skuCode: _skuCode,
									channelType: 1
								}).then(function ( d ) {									
									var resData = typeof d.data === 'object' ? d.data : JSON.parse(d.data);									
									if ( resData.result && resData.result === 1 ) {
										// 写入data
										_this.detailsRecommendCombonation = resData.obj.mdseCacheCmbVO;

										_this.$broadcast('recommendCombonationDataEvent', _this.detailsRecommendCombonation);
									} else if ( resData.result === 0 ) {
										if(resData.message){
											Toast( resData.message );
										}
										
									}
								}, function () {
									Toast('推荐组合套餐返回出错');
								});
								// 推荐组合套餐 end


							}
							this.notFound = true;
						} else if( res.result === 0 ) {
//							Toast('商品详情，请求错误');
							this.notFound = false;
							common.goNotFound();
						}
					}, function( err ) {
//						Toast('请求错误');
						common.goNotFound();
					});
				} else {
					// 404
//					_this.$route.router.go({'name': 'notfile'});
					/******** 修改404页面 ********/
					this.notFound = false;
					common.goNotFound();
					/******** 修改404页面 ********/
				}
			},

			
			// 提交订单
			bookingOrder: function () {				
				var _spuCode = this.$route.params.spuCode;
				console.info(common.urlMap);

				// // 如果渠道为微信，并且openid为空 那么跳转到下载页面
				// if(endType == 'wxCode' && (common.getCookie('wemall_openid_c')=='""' || !common.getCookie('wemall_openid_c'))){

				// 	window.location.href="http://wx.chexiangpre.com/wxoauth2/s/skipOpen.htm?targetUrl="+window.location.href.replace('#!','@');
				// 	return;
				// }
				
				// 商店消息
				var storeInfo =  {
					"storeId": 0,
			        "storeNo": "",
			        "storeName": "",
			        "provinceId": 0,
			        "provinceName": "",
			        "cityId": 0,
			        "cityName": "",
			        "distId": 0,
			        "distName": "",
			        "partnerCode":''
				}
				
				// 车型消息
				var carModelInfo = {
					"carId": '',
					"carName": '',
					"plates": '',
					"mouldId": '',
					"mdmId": '', 
					"carYear": ''
				}

				for ( var i in storeInfo ) {
					storeInfo[i] = this.storeInfo[i]; 
				}
				
				for ( var j in carModelInfo ) {
					carModelInfo[j] = this.carInfo[j];
				}

				var message = ['请选择服务车型','请选择服务门店'];				

				//强弱关联 是否有车
				if(this.carRelation && !carModelInfo.carName){
					Toast(message[0]);
					return;
				}

				//是否有门店信息
				if(!storeInfo.storeName){
					Toast(message[1]);
					return;
				}

				// 获取维度
				var ShoppingCartVo = {
					"productList": [
						{"code": this.skuCode}
					],
					"storeInfo": storeInfo,
					"carModelInfo": carModelInfo
				}
				
				this.$http.post(common.isdev() + '/detail/checkMdse.htm', {
					shoppingCartVo: JSON.stringify(ShoppingCartVo)
				}).then(function ( d ) {
					var resData = typeof d.body === 'object' ? d.body : JSON.parse(d.body);
					if ( resData.result == 0 ){

						Toast(common.queryCodeMessage(resData));
						this.isSale=false;						
					} else if ( resData.result == 1 ) {
						


						// 如果渠道为微信，并且openid为空 那么跳转到下载页面
						if(endType == 'wxCode' && (common.getCookie('wemall_openid_c')=='""' || !common.getCookie('wemall_openid_c'))){
							var userinfo = window.location.href.substring(window.location.href.indexOf("userInfo="))
							window.location.href="http://wx.chexiang.com/wxoauth2/s/getOpenId4CXJ.htm?targetUrl="+'//'+window.location.hostname+'/spah5/@/orderservice?skuCodes='+encodeURI('[' + this.skuCode + ']')+'&'+userinfo;
							return;
						}else{
							// 验证通过
							this.$route.router.go({'name': 'confirm-order-service', 'query': { 'skuCodes':  encodeURI('[' + this.skuCode + ']') }});
						}

						
					} else if(resData.result == -99){	

						common.goLogin();
					}
					
				}, function ( err ) {
					if(err){
						Toast(err);
					}
					
				});
			},
			
			/**
			 * 处理URL参数
			 * @param {String} url 字符串url参数
			 * @return {Object} 参数的对象
			 */
			getUrlParam: function ( url ) {
				var arr = [], temp = {}, _url = '';
				
				if ( url && url != 'undefined' && url != 'null' ) {
					// 是否存在 '?'
					_url = url.indexOf('?') > -1 ? url.substr(1) : url; 
					arr = _url.split('&');
					
					for ( var i=0; i<arr.length; i++ ) {
					 temp[arr[i].split('=')[0]] = arr[i].split('=')[1];
					}
					
				}
				
				return temp;
			}
		}
	}

</script>

<style lang="scss">

@import "../../assets/css/_functions.scss";
@import "../../assets/css/_variables.scss";
@import "../../assets/css/messagebox.scss";
	
.details-index {
	font-family: $sans-serif;

	.manager{
		position: fixed;
		bottom:rem(100);
		right:rem(15);
		background:#fff;
		width:rem(62);
		height:rem(62);
		overflow:hidden;
		text-align:center;
		border:1px solid rgba(204, 204, 204, .7);
		-webkit-box-shadow:0 0 20px rgba(204, 204, 204, .7);  
		-moz-box-shadow:0 0 20px rgba(204, 204, 204, .7);  
		box-shadow:0 0 20px rgba(204, 204, 204, .7); 
		font-size:rem(12);
		color:#243742;
		border-radius:5px;
		.icon-manager{
			margin:rem(8) rem(19);
		}
	}
	.bespeakbox{
		position: fixed;
		bottom: 0;
		background:$_fff;
		padding:rem(12) rem(20);
		width:rem(375);
		-webkit-box-shadow:0 0 20px rgba(204, 204, 204, .7);  
		-moz-box-shadow:0 0 20px rgba(204, 204, 204, .7);  
		box-shadow:0 0 20px rgba(204, 204, 204, .7);  
	}
	.bespeak {
		

		.order, .not-sales {
			display: block;
			text-align: center;
			width: rem(148);
			font-family: "Microsoft YaHei" !important;
			height: rem(45);
			line-height: rem(48);
			font-size: rem(18);
			border: none;
			outline: none;
			background: $_ccc;
			color: $_fff;
			float:right;

		}
		.order {
			background: $_ff6600;
			color: $_fff;
			border-radius: 5px;
		}
	}
}

</style>